*** Left-Right-Position, Party Affiliation and Regional Differences Explain Low Covid-19 Vaccination Rates in Germany
*** Sebastian Jäckle & James K. Timmis

* set path
cd "YOURPATH\replication"


clear all
version 15
set scheme plottig

*********************************************************
***
*** 		PART I: Official Vaccination Data
***
*********************************************************
* Figure 1: vaccination rates by producer

	* import data: 
	* SOURCE:  https://github.com/robert-koch-institut/COVID-19-Impfungen_in_Deutschland; 
	* only full vaccinations counted, i.e. second dose of Astra-Zeneca, Biontech and Moderna, first dose of Johnson&Johnson
	
	*import delimited "data\vaccinations by producer.csv", clear
	import delimited "data\Bundeslaender_COVID-19-Impfungen_08.12.2021.csv", clear

	
	* convert datestring to Stata date format
	gen edate = date(date, "DMY")
	format edate %tddd._Mon
	drop date
	
	* calculate non vaccinated
	gen nonvaccinated = 83.19951-(astrazeneca+moderna+johnsonjohnson+biontech)
	label variable nonvaccinated "not fully vaccinated"
	
	* graph data als Line -Graph
	twoway (line nonvaccinated edate) (line biontech edate) (line moderna edate) (line astrazeneca edate)  (line johnsonjohnson edate)  , 		///
	xtitle("") 																																	///
	ytitle("Persons (in millions)")																												///
	xlabel(#10)																																	///
	legend(cols(5) position(6) ring(3))
	graph export "dump\fig_1_line.pdf", replace
	graph export "dump\fig_1_line.emf", replace

	* as stacked barplot
	graph bar (sum) astrazeneca   johnsonjohnson moderna biontechpfizer nonvaccinated, ///
	ytitle("Percent of population")																												///
	over(edate, relabel(1 "01.01.2021"  )  ) stack percent ///
	bar(1, bfcolor(yellow*0.6) blcolor(yellow*0.6)) ///
	bar(2, bfcolor(red*0.6) blcolor(red*0.6)) ///
	bar(3, bfcolor(blue*0.6) blcolor(blue*0.6)) ///
	bar(4, bfcolor(green*0.6) blcolor(green*0.6)) ///
	bar(5, bfcolor(black*0.3) blcolor(black*0.3))
	
	* as stacked area-plot
	gen percent1 = astrazeneca / (astrazeneca +  johnsonjohnson + moderna + biontechpfizer + nonvaccinated) *100
	gen percent2 = (astrazeneca +  johnsonjohnson)/ (astrazeneca +  johnsonjohnson + moderna + biontechpfizer + nonvaccinated) *100
	gen percent3 = (astrazeneca +  johnsonjohnson + moderna)/ (astrazeneca +  johnsonjohnson + moderna + biontechpfizer + nonvaccinated) *100
	gen percent4 = (astrazeneca +  johnsonjohnson + moderna + biontechpfizer)/ (astrazeneca +  johnsonjohnson + moderna + biontechpfizer + nonvaccinated) *100
	gen percent5 = 100
	gen zero = 0 
	twoway rarea zero percent1 edate, color(magenta*0.5) fintensity(80) /// 
    || rarea percent1 percent2 edate /// 
    || rarea percent2 percent3 edate, color(orange*0.5) fintensity(80)  /// 
	|| rarea percent3 percent4 edate, color(green*0.5) fintensity(80)  /// 
	|| rarea percent4 percent5 edate, color(red*0.5) fintensity(80)  /// 
    ||, legend(order(5 "not (fully) vaccinated" 4 "Comirnaty (BionTech/Pfizer)" 3 "Spikevax (Moderna)" 2 "Janssen COVID-19 Vaccine (Johnson&Johnson)" 1 "Vaxzevria (AstraZeneca)")) /// 
     xlabel(#10) ytitle("Percent of Population") xtitle("") legend(rows(3) position(6) ring(3))
	 graph export "fig\fig_1.pdf", replace
	graph export "fig\fig_1.emf", replace
	
	* color-blind version
	set scheme plottigblind
		twoway rarea zero percent1 edate /// 
    || rarea percent1 percent2 edate /// 
    || rarea percent2 percent3 edate /// 
	|| rarea percent3 percent4 edate /// 
	|| rarea percent4 percent5 edate /// 
    ||, legend(order(5 "not (fully) vaccinated" 4 "Comirnaty (BionTech/Pfizer)" 3 "Spikevax (Moderna)" 2 "Janssen COVID-19 Vaccine (Johnson&Johnson)" 1 "Vaxzevria (AstraZeneca)")) /// 
     xlabel(#10) ytitle("Percent of Population") xtitle("") legend(rows(2) position(6) ring(3))
	 graph export "dump\fig_1_area_colorblind.pdf", replace
	graph export "dump\fig_1_area_colorblind.emf", replace
	
	
*********************************************************
***
*** 		PART II: Individual Survey Data
***
*********************************************************

clear all 

ssc install mplotoffset

* WAVE 1 - February 2021
use "data\W1_Feb21.dta"

* change missing codes 0 --> .

	mvdecode v_363, 	mv(0)
	mvdecode v_364,		mv(0)
	mvdecode v_365,		mv(0)
	mvdecode v_366,		mv(0)
	mvdecode v_368,		mv(0)
	mvdecode v_369,		mv(0)
	mvdecode v_370,		mv(0)
	mvdecode v_371,		mv(0)
	mvdecode v_372,		mv(0)
	mvdecode v_374,		mv(0)
	mvdecode v_217,		mv(0)
	mvdecode v_144,		mv(0)
	mvdecode v_145,		mv(0)
	mvdecode v_484,		mv(0)
	mvdecode v_486,		mv(0)
	mvdecode v_488,		mv(0)
	mvdecode v_490,		mv(0)
	mvdecode v_491,		mv(0)
	mvdecode v_492,		mv(0)
	mvdecode v_493,		mv(0)
	mvdecode v_494,		mv(0)
	mvdecode v_495,		mv(0)
	mvdecode v_553,		mv(0)
	mvdecode v_554,		mv(0)
	mvdecode v_556,		mv(0)
	mvdecode v_557,		mv(0)
	mvdecode v_344,		mv(0)
	mvdecode v_767,		mv(0)
	mvdecode v_768,		mv(0)
	mvdecode v_774,		mv(0)
	mvdecode v_770,		mv(0)
	mvdecode v_775,		mv(0)
	mvdecode v_389,		mv(0)
	mvdecode v_42, 		mv(0)
	mvdecode v_342,	 	mv(0)
	mvdecode v_498, 	mv(0)
	mvdecode v_502_a, 	mv(0)
	mvdecode geschlecht,mv(0)	
	mvdecode v_505, 	mv(0)
	mvdecode v_167,		mv(0)
	mvdecode v_172,		mv(0)
	mvdecode v_173,		mv(0)
	mvdecode f3_1l,		mv(0)	
	mvdecode f3_2l,		mv(0)
	mvdecode f3_3l,		mv(0)
	mvdecode f3_4l,		mv(0)
	mvdecode f3_5l,		mv(0)
	mvdecode f3_7l,		mv(0)
	mvdecode v_170,		mv(0)
	mvdecode v_171,		mv(0)
	mvdecode v_267, 	mv(0)
	mvdecode v_230, 	mv(0)
	mvdecode v_231, 	mv(0)
	mvdecode v_232, 	mv(0)
	mvdecode v_233, 	mv(0)
	mvdecode v_375,		mv(0)
	mvdecode v_376,		mv(0)
	mvdecode v_377,		mv(0)
	mvdecode v_378,		mv(0)
	mvdecode v_379,		mv(0)
	mvdecode v_296, 	mv(0)
	mvdecode v_297, 	mv(0)
	mvdecode v_287,     mv(0)
	mvdecode v_274,     mv(0)
	mvdecode v_291,     mv(0)
	mvdecode v_292,     mv(0)
	
	replace bundesland = . if bundesland == 0
	replace bundesland = . if bundesland == 17
	
label define bundesland 1 "Baden-Wuerttemberg" 2 "Bavaria" 3 "Berlin" 4 "Brandenburg" 5 "Bremen" 6 "Hamburg" 7 "Hesse" 8 "Mecklenburg-Vorpommern" 9 "Lower Saxony" 10 "North Rhine-Westphalia" 11 "Rhineland Palatinate" 12 "Saarland" 13 "Saxony" 14 "Saxony-Anhalt"  15 "Schleswig Holstein" 16 "Thuringia"
label values bundesland bundesland

* gender including non-binary
	gen gender = geschlecht

	* gender (including non-binary)
	label define gender 1 "male" 2 "female" 3 "non-binary" 
	label values gender gender	
	
	* gender = non-binary --> .
	mvdecode geschlecht, mv(3)
* male
	tab geschlecht, gen(n)
	rename n1 male
	label define male 0 "female" 1 "male"
	label value male male	
	
* still at school --> .
	mvdecode v_505, mv(1)

*** Dependent Variable Political Trust (specific trust & diffuse trust)

	* precheck for index construction
	pwcorr v_363 - v_371, obs sig
	factor v_363 - v_371
	rotate
	estat kmo
	alpha v_363 - v_371, item
	
	* specific trust in Government, chancelor, Bundestag, prime minister land
	alpha v_363 v_364 v_368 v_370, item
	gen spectrust = (v_363 + v_364 + v_368 + v_370)/4
	
	* diffuse trust in political system
	alpha v_365 v_366 v_369 v_371, item
	factor v_365 v_366 v_369 v_371
	rotate
	estat kmo
	gen difftrust = (v_365 + v_366 + v_369 + v_371)/4
	
*** Independent Variables	
	
	* acceptance of anti-Covid-19 measures 
	* precheck for index construction
	pwcorr v_484 - v_495, obs sig
	factor v_484 - v_495
	rotate
	estat kmo
	alpha v_484 - v_495, item
	gen covid19_measures = (v_486 + v_488 + v_490 + v_491 + v_492 + v_493 + v_494 + v_495)/8
	
	* evaluation of actual government measures (-4: completely against government measures; + 4 completely in favor of government measures)
	* precheck for index construction
	pwcorr v_553 v_554 v_556 v_557, obs sig
	factor v_553 v_554 v_556 v_557
	rotate
	estat kmo
	alpha v_553 v_554 v_556 v_557, item
	gen govmeasures = (v_553 + v_554)/2 - (v_556 + v_557)/2
	
	* biggest fear
	gen biggest_fear = .
	replace biggest_fear = 1 if v_152 == 1
	replace biggest_fear = 2 if v_153 == 1
	replace biggest_fear = 3 if v_154 == 1
	replace biggest_fear = 4 if v_155 == 1
	replace biggest_fear = 5 if v_156 == 1
	replace biggest_fear = 6 if v_157 == 1
    label define biggest_fear 1 "unemployment" 2 "illness" 3 "economic crash" 4 "restrictions of lifestyle habits" 5 "restrictions of democratic rights" 6 "loneliness"
	label value biggest_fear biggest_fear	
	
	* Mediatrust (classic media & social media + Difference between the two)
	recode f3_1l (1=1) (2=0.5) (3=0), gen(mt_newspapers)
	recode f3_2l (1=1) (2=0.5) (3=0), gen(mt_socialmedia)
	recode f3_3l (1=1) (2=0.5) (3=0), gen(mt_privatetv)
	recode f3_4l (1=1) (2=0.5) (3=0), gen(mt_blogsyoutube)
	recode f3_5l (1=1) (2=0.5) (3=0), gen(mt_magazine)
	recode f3_6l (1=1) (2=0.5) (3=0), gen(mt_onlinemedia)
	recode f3_7l (1=1) (2=0.5) (3=0), gen(mt_radio)
	recode v_170 (1=1) (2=0.5) (3=0), gen(mt_publicbroadcast)
	recode v_171 (1=1) (2=0.5) (3=0), gen(mt_official)

	alpha mt_news mt_private mt_magazine mt_radio mt_public mt_official mt_onlinemedia, item 
		* --> exclude private tv from the scale
	gen mediatrust_classic = (mt_news + mt_magaz + mt_radio + mt_public + mt_offic + mt_onlinemedia)/6
	
	
	alpha mt_blogsyoutube mt_socialmedia 
	gen mediatrust_socialmedia = (mt_socialmedia + mt_blogsyoutube)/2
	gen dif_mediatrust = mediatrust_classic - mediatrust_socialmedia
	
	* incomeloss
	recode v_172 (1=5) (2=4) (3=3) (4=2) (5=1), gen(incomenow)
	label define incomenow 1 "find it very difficult to make ends meet" 5 "can live very comfortably on the income"
	label value incomenow incomenow
	recode v_173 (1=5) (2=4) (3=3) (4=2) (5=1), gen(incomebefore)
	label define incomebefore 1 "find it very difficult to make ends meet" 5 "can live very comfortably on the income"
	label value incomebefore incomevefore
	gen incomeloss = incomebefore-incomenow
	
	* age
	gen age = 2020 - v_496
	
	* highest educational attainment
	recode v_505 (2/3=1)(4=2)(5=3) (6=4) (7=5), gen (v_505_a)
	label define edu 1 "School dropout & secondary school graduation (ISCED 2)" 2 "Secondary school leaving certificate (ISCED 2)" 3 "Advanced technical college certificate (ISCED 3)" 4 "General university entrance certificate (ISCED 3)" 5 "University degree (ISCED 5a)"
	label value v_505_a edu
	
	tab v_505_a, gen(p)
	rename p1 ohne_hauptschule
	rename p2 mittlere_reife
	rename p3 fachhochschulreife
	rename p4 abitur
	rename p5 studium
	
	gen education = v_505_a
	label value education edu
	
	* healthstate
	recode v_498 (1=5) (2=4) (3=3) (4=2) (5=1), gen(healthstate)
	label define healthstate 1 "very bad" 5 "very good"
	label value healthstate healthstate
	
	* links-rechts 0-1
	gen left_right = (v_42 -1)/10
	label define left_right 0 "links" 1 "rechts"
	label value left_right left_right
	
	* political extremism (0 = middle category, 5 = most extreme)
	gen pol_extr = abs(6-v_42)
	table pol_extr
	
	* householdsize 3+
	recode v_502_a (1/2=0) (3/34=1), gen(hh3andmore)
	label define hh3andmore 0 "householdsize < 3" 1 "householdsize >= 3"
	label values hh3andmore hh3andmore
	
	* children in household (only asked in wave 2 & wave 3) 
	recode v_230 (1=0) (2=1) (3=2) (4=3), gen(children_0_2)
	recode v_231 (1=0) (2=1) (3=2) (4=3), gen(children_3_6)
	recode v_232 (1=0) (2=1) (3=2) (4=3), gen(children_7_10)
	recode v_233 (1=0) (2=1) (3=2) (4=3), gen(children_11_18)
	
	egen children_total = rowtotal(children_0_2  children_3_6  children_7_10  children_11_18)
		* children small: (0-10)
	egen children_small = rowtotal(children_0_2  children_3_6  children_7_10)
		* both children variables in wave 1 --> NA
	replace children_total = . if welle ==1
	replace children_small = . if welle ==1
	 
	
	* authoritarianism
		* precheck for index construction
	pwcorr v_375-v_379, obs sig
	factor v_375-v_379
	rotate
	estat kmo
	alpha v_375-v_379, item 
		* index using the mean of the five authoritarianism questions
	gen auth = (v_375 + v_376 + v_377 + v_378 + v_379)/5
	
	* voting intention
	label define vote_intent 1 "Christian democratic CDU/CSU" 2 "Social democratic SPD" 3 "Left Party" 4 "Greens" 5 "Liberal FDP" 6 "Right-wing populist AfD" 7 "Others" 8 "Will not vote" 9 "Not eligible to vote"
	label values v_167 vote_intent

	* voting intention incl. protest_party
	gen vote_int = v_167
	replace vote_int = 10 if v_167 == 9
	replace vote_int = 9 if v_167 == 8
	replace vote_int = 8 if v_167 == 7
	replace vote_int = 7 if v_168 == "Alternative Partei die mit den Altoarteien abrechnet"
	replace vote_int = 7 if v_168 == "Aus Protest, nicht aus Überzeugung"
	replace vote_int = 7 if v_168 == "Basis"
	replace vote_int = 7 if v_168 == "Basis Demokraten"
	replace vote_int = 7 if v_168 == "Basis Partei"
	replace vote_int = 7 if v_168 == "Basis demokratische Partei"
	replace vote_int = 7 if v_168 == "Basis-Partei"
	replace vote_int = 7 if v_168 == "Basisdemikratische Partei"
	replace vote_int = 7 if v_168 == "Basisdemokratische Partei Deutschland"
	replace vote_int = 7 if v_168 == "Basisdemokratische Partei Deutschland   Kurzform - dieBasis"
	replace vote_int = 7 if v_168 == "Basisdemokratische Partei Deutschland, dieBasis"
	replace vote_int = 7 if v_168 == "Basisdemokratische Partei Deutschlands"
	replace vote_int = 7 if v_168 == "Basispartei"
	replace vote_int = 7 if v_168 == "DIE BASIS"
	replace vote_int = 7 if v_168 == "Die Baisis"
	replace vote_int = 7 if v_168 == "Die Basis"
	replace vote_int = 7 if v_168 == "Die Basis (Basisdemokratische Partei Deutschland)"
	replace vote_int = 7 if v_168 == "Die Basis oder andere zB wir2020"
	replace vote_int = 7 if v_168 == "Die Basisdemokratische Partei Deutschland"
	replace vote_int = 7 if v_168 == "Die basis"
	replace vote_int = 7 if v_168 == "Die basisdemokratische Partei Deutschland"
	replace vote_int = 7 if v_168 == "DieBasis"
	replace vote_int = 7 if v_168 == "Eine Partei die sinnvoller mit der Krise umgeht."
	replace vote_int = 7 if v_168 == "Eine andere Partei - zb. Widerstand2020"
	replace vote_int = 7 if v_168 == "Eine sich aus der Krise entwickelnde neue partei"
	replace vote_int = 7 if v_168 == "Erst immer ,,Freie Wähler  , sobald jetzt Wahlen wären, ,, Widerstand2020"
	replace vote_int = 7 if v_168 == "Protestpartei"
	replace vote_int = 7 if v_168 == "Protestwahl / ungültige Stimme"
	replace vote_int = 7 if v_168 == "Protestwahl je nachdem, welche Partei(en) zugelassen sind"
	replace vote_int = 7 if v_168 == "Protestwähler"
	replace vote_int = 7 if v_168 == "Querdenker, sofern sie antreten"
	replace vote_int = 7 if v_168 == "WID 2020"
	replace vote_int = 7 if v_168 == "WIDERSTAND 2020"
	replace vote_int = 7 if v_168 == "WIR 2020"
	replace vote_int = 7 if v_168 == "WIR Partei"
	replace vote_int = 7 if v_168 == "WIR, Querdenkerliste"
	replace vote_int = 7 if v_168 == "WIR2020"
	replace vote_int = 7 if v_168 == "Widerstand 2020"
	replace vote_int = 7 if v_168 == "Widerstand 2020 oder eine andere möglichst direktdemokratische Partei"
	replace vote_int = 7 if v_168 == "Widerstand 202ü"
	replace vote_int = 7 if v_168 == "Widerstand d2020"
	replace vote_int = 7 if v_168 == "Widerstand/Wir2020"
	replace vote_int = 7 if v_168 == "Widerstand20"
	replace vote_int = 7 if v_168 == "Widerstand2000"
	replace vote_int = 7 if v_168 == "Widerstand2020"
	replace vote_int = 7 if v_168 == "Widerstand2020 Deutschland"
	replace vote_int = 7 if v_168 == "Widerstand2020 das Original"
	replace vote_int = 7 if v_168 == "Widerstand2020/WIR2020"
	replace vote_int = 7 if v_168 == "Widerstand2029"
	replace vote_int = 7 if v_168 == "Widerstandspartei"
	replace vote_int = 7 if v_168 == "Widerstandspartei 2020"
	replace vote_int = 7 if v_168 == "Widestand2020"
	replace vote_int = 7 if v_168 == "Widetstand2020"
	replace vote_int = 7 if v_168 == "Wiederstand 2020"
	replace vote_int = 7 if v_168 == "Wiederstand2020"
	replace vote_int = 7 if v_168 == "Wir 2020"
	replace vote_int = 7 if v_168 == "Wir 2020 oder die Partei"
	replace vote_int = 7 if v_168 == "Wir2020"
	replace vote_int = 7 if v_168 == "Wir2020 oder die Basis"
	replace vote_int = 7 if v_168 == "Wir2020-partei"
	replace vote_int = 7 if v_168 == "die Basis"
	replace vote_int = 7 if v_168 == "die aus der/den neuen Bewegung/en kommen wird"
	replace vote_int = 7 if v_168 == "die basis"
	replace vote_int = 7 if v_168 == "die hoffentlich noch kommt und den Wahnsinn stoppt!"
	replace vote_int = 7 if v_168 == "dieBasis"
	replace vote_int = 7 if v_168 == "dieBasis-Partei"
	replace vote_int = 7 if v_168 == "evtl. Wir2020"
	replace vote_int = 7 if v_168 == "querdenken 21"
	replace vote_int = 7 if v_168 == "widerstand 2020"
	replace vote_int = 7 if v_168 == "widerstand2020"
	replace vote_int = 7 if v_168 == "wiederstand 2020"
	replace vote_int = 7 if v_168 == "wiederstand20202"
	replace vote_int = 7 if v_168 == "wir"
	replace vote_int = 7 if v_168 == "wir 2020"
	replace vote_int = 7 if v_168 == "wir2020"
	replace vote_int = 7 if v_168 == "wir2020-Partei"
	replace vote_int = 7 if v_168 == "zb (aber nicht zwingend) Widerstand2020"
	replace vote_int = . if vote_int == .b
	
	label define vote_intent2 1 "Christian democratic CDU/CSU" 2 "Social democratic SPD" 3 "Left Party" 4 "Greens" 5 "Liberal FDP" 6 "Right-wing populist AfD" 7 "Protest party" 8 "Others" 9 "Will not vote" 10 "Not eligible to vote"
	label values vote_int vote_intent2	

* agegroup
gen agegroup = .
replace agegroup = 6 if v_496 <= 1956
replace agegroup = 5 if v_496 > 1956 & v_496 <= 1966
replace agegroup = 4 if v_496 > 1966 & v_496 <= 1976
replace agegroup = 3 if v_496 > 1976 & v_496 <= 1986
replace agegroup = 2 if v_496 > 1986 & v_496 <= 1996 
replace agegroup = 1 if v_496 > 1996

label define agegroup 6 ">64" 5 "55-64" 4 "45-54" 3 "35-44" 2 "25-34" 1 "<25"
label value agegroup agegroup

* erste Impfung bereits erhalten
tab v_296

* Haben Sie vor sich gegen das Corona-Virus impfen zu lassen? (q_9085008 - Typ 111)				
tab v_297 

gen vacc = v_297
replace vacc = 1 if v_296 == 1

recode v_291 (1 = 1) (2 = 0), gen(own_behavior_mask)
recode v_292 (1 = 1) (2 = 0), gen(own_behavior_app)

* east_west_south
recode bundesland (1 2 = 3) (3 4 8 13 14 16 = 1) (5 6 7 9 10 11 12 15 = 2), gen(east_west_south)
label define east_west_south 1 "East" 2 "North/West" 3 "South"
label value east_west_south east_west_south

* east_west_south_b (berlin bei West)
recode bundesland (1 2 = 3) (4 8 13 14 16 = 1) (3 5 6 7 9 10 11 12 15 = 2), gen(east_west_south_b)
label define east_west_south_b 1 "East" 2 "North/West" 3 "South"
label value east_west_south_b east_west_south_b

gen household_income = v_172
label define household_income  5 "Cope only with extreme difficulties" 4 "Cope with some difficulties" 3 "Cope" 2 "Live comfortably" 1 "Live very comfortably" 7 "Does not apply - no own household income yet"
label value household_income household_income

save "dump\forlabels.dta", replace

	* nach geschlecht
	tab geschlecht v_297, row 
	
	* nach Alter
	tab agegroup v_297, row
	
	* nach Bundesland
	tab bundesland v_297, row
	
	* nach politischenm Interesse
	tab v_342 v_297, row
	
	* nach links-rechts
	tab left_right v_297, row
	
	* nach Sonntagsfrage
	tab vote_int v_297, row
	
	* nach Gesundheitszustand
	tab healthstate v_297, row
	
	* nach persönlicher Betroffenheit
	* Ich war bzw. bin aufgrund eines Corona-Verdachts in Quarantäne
	tab v_287 v_297, row
	
	* Wie viele Personen kennen Sie persönlich, die positiv auf das Corona-Virus getestet wurden? (q_8591149 - Typ 111)
	tab v_274 v_297, row
	
	* nach Bildungsabschluss
	tab v_505_a v_297, row
	
	* nach KIinder in Haushalt
	tab v_267 v_297, row
	
	* nach Haushaltseinkommen
	tab v_172 v_297, row
	
	* nach Sichtweise zu Reglementierung
	* Um die Sicherheit und das Wohlergehen der Menschen zu garantieren, sollte der Staat notfalls Rechte des Einzelnen einschränken.
	tab v_389 v_297, row
	
	* nach sozialem Vertrauen
	* Ganz allgemein gesprochen: Glauben Sie, dass man den meisten Menschen vertrauen kann oder dass man im Umgang mit anderen Menschen nicht vorsichtig genug sein kann? (q_7914432 - Typ 340)				
	tab v_344 v_297, row


	*** Regression
	
	* b10 = NRW als Referenz
	* Modell A: Alter linear
	reg vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_1a.ster", replace
	
	* Modell A0: wie Modell A ohne vote_int
	reg vacc left_right b10.bundesland i.gender  age i.education  
	estimates save "dump\wave_1_base.ster", replace
	
	* Modell B: Alter in Altersgruppen	
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  
	estimates save "dump\wave_1b.ster", replace	
	
	* Modell C: household_income
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  i.household_income
	estimates save "dump\wave_1c.ster", replace	

	* Modell D: migration background
	* --> fehlt in Wave 1
	
	* Modell E: own behavior
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  own_behavior_mask own_behavior_app
	estimates save "dump\wave_1e.ster", replace	
	
	* Modell F: health
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  healthstate
	estimates save "dump\wave_1f.ster", replace	
	
	* Modell G: age x sex Interaktion
	reg vacc c.left_right i.vote_int b10.bundesland i.gender##c.age i.education 
	estimates save "dump\wave_1g.ster", replace	
	quietly margins, dydx(gender) at(age=(15(5)75))
	marginsplot
	
	* Modell h: age x left_right Interaktion
	reg vacc c.left_right##c.age i.vote_int b10.bundesland i.gender i.education 
	estimates save "dump\wave_1h.ster", replace	
	quietly margins, dydx(left_right) at(age=(15(5)75))
	marginsplot
	
	* Modell i: agegroup x left_right Interaktion
	reg vacc i.agegroup##c.left_right i.vote_int  b10.bundesland i.gender   i.education 
	estimates save "dump\wave_1i.ster", replace	
	quietly margins, dydx(left_right) at(agegroup=(1(1)6))
	marginsplot, title("S1 (February 2021)") xtitle("") ytitle("Average Marginal Effect on VacHes")
	graph save "dump\age_x_leftright_w1.gph", replace
	
	* Modell j: vote x left_right
	reg vacc i.vote_int##c.left_right b10.bundesland i.gender  i.agegroup   i.education 
	quietly margins  ,  at(vote_int=(1(1)6) left_right=(0 0.5 1)) 
	marginsplot, recast(scatter) title("Wave 1")
	graph save "dump\vote_left_right_1.gph", replace
	
	* Modell k: agegroup x vote_int x gender
	reg vacc i.agegroup##i.vote_int##i.gender c.left_right b10.bundesland     i.education 
	estimates save "dump\wave_1k.ster", replace	
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S1 (February 2021) - Male") legend(row(2) size(vsmall)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				 recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w1_male.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S1 (February 2021) - Female") legend(row(2) size(vsmall)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				 recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w1_female.gph", replace
	grc1leg "dump\age_x_vote_w1_male.gph" "dump\age_x_vote_w1_female.gph", ycommon
	graph save "dump\age_x_vote_w1.gph", replace

	* Modell k: agegroup x vote_int x gender WITHOUT CI
	reg vacc i.agegroup##i.vote_int##i.gender c.left_right b10.bundesland     i.education 
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S1 (February 2021) - Male") legend(row(3) size(vsmall)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 	/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 	/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w1_male_noci.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S1 (February 2021) - Female") legend(row(3) size(vsmall)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 	/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 		/// Protest
				 recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w1_female_noci.gph", replace
	grc1leg "dump\age_x_vote_w1_male_noci.gph" "dump\age_x_vote_w1_female_noci.gph", ycommon
	graph save "dump\age_x_vote_w1_noci.gph", replace	
	
	
		
	* Modell l: east_west_south x vote_int (Berlin = East)
	reg vacc c.left_right i.east_west_south##i.vote_int i.gender  i.agegroup i.education 
	estimates save "dump\wave_1l.ster", replace	
	margins, at(east_west_south = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S1 (February 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_x_vote_w1.gph", replace

	* Modell lb: east_west_south_b x vote_int (Berlin = West)
	reg vacc c.left_right i.east_west_south_b##i.vote_int i.gender  i.agegroup i.education  
	margins, at(east_west_south_b = (1(1)3) vote_int = (1(1)8))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S1 (February 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_b_x_vote_w1.gph", replace	
	
	*** als Ologit
		* Modell A: Alter linear
	ologit vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\ol_wave_1a.ster", replace
	
	* Modell B: Alter in Altersgruppen
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education 
	estimates save "dump\ol_wave_1b.ster", replace	
	
	* Modell C: household_income
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  i.household_income
	estimates save "dump\ol_wave_1c.ster", replace	

	* Modell D: migration background
	* --> fehlt in ol_wave 1
	
	* Modell E: own behavior
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  own_behavior_mask own_behavior_app
	estimates save "dump\ol_wave_1e.ster", replace	
	
	* Modell F: health
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  health
	estimates save "dump\ol_wave_1f.ster", replace	
	
	collapse (mean) vacc_mean = vacc, by(bundesland)
	save "dump\vacc_mean_w1.dta", replace
	
clear all	
* WAVE 2 - April/Mai 2021
use "data\W2_Apr21.dta"

rename v_19 bundesland
replace bundesland = . if bundesland == 0

label define bundesland 1 "Baden-Wuerttemberg" 2 "Bavaria" 3 "Berlin" 4 "Brandenburg" 5 "Bremen" 6 "Hamburg" 7 "Hesse" 8 "Mecklenburg-Vorpommern" 9 "Lower Saxony" 10 "North Rhine-Westphalia" 11 "Rhineland Palatinate" 12 "Saarland" 13 "Saxony" 14 "Saxony-Anhalt"  15 "Schleswig Holstein" 16 "Thuringia"
label values bundesland bundesland

gen gender =  v_370 
	* gender (including non-binary)
	label define gender 1 "male" 2 "female" 3 "non-binary" 
	label values gender gender	

	* gender = non-binary --> .
	mvdecode v_370, mv(3)
* male
	tab v_370, gen(n)
	rename n1 male
	label define male 0 "female" 1 "male"
	label value male male

gen age = v_125	

* agegroup
gen agegroup = .
replace agegroup = 6 if v_125 > 64 
replace agegroup = 5 if v_125 > 54 & v_125 <= 64
replace agegroup = 4 if v_125 > 44 & v_125 <= 54
replace agegroup = 3 if v_125 > 34 & v_125 <= 44
replace agegroup = 2 if v_125 > 24 & v_125 <= 34 
replace agegroup = 1 if v_125 > 15 & v_125 <= 24

label define agegroup 6 ">64" 5 "55-64" 4 "45-54" 3 "35-44" 2 "25-34" 1 "<25"
label value agegroup agegroup

recode v_20 (1 2 9 =1) (3 5 = 2) (4 11 = 4) (10 12 = 3)(7 = 5), gen(education)
label define edu 1 "Schulabbruch & Hauptschulabschluss (ISCED 2)" 2 "Mittlere Reife (ISCED 2)" 3 "Fachhochschulreife (ISCED 3)" 4 "Abitur (ISCED 3)" 5 "Hochschulabschluss (ISCED 5a)"
label value education edu

* east_west_south
recode bundesland (1 2 = 3) (3 4 8 13 14 16 = 1) (5 6 7 9 10 11 12 15 = 2), gen(east_west_south)
label define east_west_south 1 "East" 2 "North/West" 3 "South"
label value east_west_south east_west_south

* east_west_south_b (berlin bei West)
recode bundesland (1 2 = 3) (4 8 13 14 16 = 1) (3 5 6 7 9 10 11 12 15 = 2), gen(east_west_south_b)
label define east_west_south_b 1 "East" 2 "North/West" 3 "South"
label value east_west_south_b east_west_south_b

* links-rechts 0-1
gen left_right = (v_773 -1)/10
label define left_right 0 "links" 1 "rechts"
label value left_right left_right

* party affiliation als proxy für vote_int
recode parteineigung (1 =1) (2=2) (5 = 3) (3 = 4) (4 = 5) (6 = 6) (9 = 7) (0 = .) (else = 8), gen(vote_int)
label define vote_intent2 1 "CDU/CSU" 2 "SPD" 3 "Left Party" 4 "Greens" 5 "FDP" 6 "AfD" 7 "Protest party" 8 "Others" 9 "Würde nicht wählen" 10 "Nicht wahlberechtigt"
	label values vote_int vote_intent2	


gen migration = v_57
replace migration = 0 if v_57 == 2

recode impfen (1 2 = 1) (3 = 2) (4 = 3) (5 = 4) (6 = 5), gen(vacc)

recode v_871 (1 = 1) (2 = 0), gen(own_behavior_mask)
recode v_872 (1 = 1) (2 = 0), gen(own_behavior_app)

* erste Impfung bereits erhalten
tab v_874

* nach Geschlecht
tab v_370 impfen, row

* nach Migrationshintergrund
tab v_57 impfen, row

* nach Altersgruppe
tab agegroup impfen, row

* nach Bildungsabschluss
tab v_20 impfen, row

* nach Bundesland
tab v_19 impfen, row

* nach Parteineigung
tab parteineigung impfen, row

* nach links-rechts
tab left_right impfen, row

	*** Regression
	
	* b10 = NRW als Referenz
	* Modell A: Alter linear
	reg vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_2a.ster", replace
	
	* Modell A0: wie Modell A ohne vote_int
	reg vacc left_right  b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_2_base.ster", replace

	* Modell B: Alter in Altersgruppen	
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  
	estimates save "dump\wave_2b.ster", replace	
	
	* Modell C: household_income
	* --> fehlt in wave 2	

	* Modell D: migration background
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\wave_2d.ster", replace	
	
	* Modell E: own behavior
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  own_behavior_mask own_behavior_app
	estimates save "dump\wave_2e.ster", replace	
	
	* Modell F: health
	* --> fehlt in wave 2	
	
	* Modell G: age x sex Interaktion
	reg vacc c.left_right i.vote_int b10.bundesland i.gender##c.age i.education 
	estimates save "dump\wave_2g.ster", replace	
	
	* Modell h: age x left_right Interaktion
	reg vacc c.left_right##c.age i.vote_int b10.bundesland i.gender i.education 
	estimates save "dump\wave_2h.ster", replace	
	
	* Modell i: age x left_right Interaktion
	reg vacc i.agegroup##c.left_right i.vote_int b10.bundesland i.gender   i.education 
	estimates save "dump\wave_2i.ster", replace	
	quietly margins , dydx(left_right ) at(agegroup=(1(1)6))
	marginsplot, title("S2 (May 2021)") xtitle("") ytitle("")
	graph save "dump\age_x_leftright_w2.gph", replace
	
	* Modell j: vote x left_right
	reg vacc i.vote_int##c.left_right b10.bundesland i.gender  i.agegroup   i.education 
	quietly margins  ,  at(vote_int=(1(1)6) left_right=(0 0.5 1)) 
	marginsplot, recast(scatter) title("Wave 2")
	graph save "dump\vote_left_right_2.gph", replace
	
	* Modell k: agegroup x vote_int x gender
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender b10.bundesland      i.education 
	estimates save "dump\wave_2k.ster", replace	
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S2 (May 2021) - Male") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w2_male.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S2 (May 2021) - Female") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w2_female.gph", replace
	grc1leg "dump\age_x_vote_w2_male.gph" "dump\age_x_vote_w2_female.gph", ycommon
	graph save "dump\age_x_vote_w2.gph", replace
	
	* Modell k: agegroup x vote_int x gender NOCI
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender b10.bundesland      i.education 
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S2 (May 2021) - Male") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 	/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 	/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w2_male_noci.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S2 (May 2021) - Female") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 	/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 	/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w2_female_noci.gph", replace
	grc1leg "dump\age_x_vote_w2_male_noci.gph" "dump\age_x_vote_w2_female_noci.gph", ycommon
	graph save "dump\age_x_vote_w2_noci.gph", replace	
	
	* Modell l: east_west_south x vote_int
	reg vacc c.left_right  i.east_west_south##i.vote_int i.gender  i.agegroup i.education 
	estimates save "dump\wave_2l.ster", replace	
	margins, at(east_west_south = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S2 (May 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_x_vote_w2.gph", replace	
	
	* Modell lb: east_west_south_b x vote_int
	reg vacc c.left_right i.east_west_south_b##i.vote_int i.gender  i.agegroup i.education 
	margins, at(east_west_south_b = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S2 (May 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_b_x_vote_w2.gph", replace	
	
	*** als Ologit
		* Modell A: Alter linear
	ologit vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\ol_wave_2a.ster", replace
	
	* Modell B: Alter in Altersgruppen
	ologit vacc left_right i.vote_int  b10.bundesland i.gender  i.agegroup i.education 
	estimates save "dump\ol_wave_2b.ster", replace	
	
	* Modell C: household_income
	* --> fehlt in wave 2	

	* Modell D: migration background
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\ol_wave_2d.ster", replace	

	* Modell E: own behavior
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education own_behavior_mask own_behavior_app
	estimates save "dump\ol_wave_2e.ster", replace	
	
	* Modell F: health
	* --> fehlt in wave 2		

	collapse (mean) vacc_mean = vacc, by(bundesland)
	save "dump\vacc_mean_w2.dta"	, replace
	
clear all	
* WAVE 3 - Juli/August 2021
use "data\W3_Jul21.dta"

* change missing codes 0 --> .

	mvdecode v_370, 	mv(0)


rename v_19 bundesland
replace bundesland = . if bundesland == 0
	
label define bundesland 1 "Baden-Wuerttemberg" 2 "Bavaria" 3 "Berlin" 4 "Brandenburg" 5 "Bremen" 6 "Hamburg" 7 "Hesse" 8 "Mecklenburg-Vorpommern" 9 "Lower Saxony" 10 "North Rhine-Westphalia" 11 "Rhineland Palatinate" 12 "Saarland" 13 "Saxony" 14 "Saxony-Anhalt"  15 "Schleswig Holstein" 16 "Thuringia"
label values bundesland bundesland

gen gender =  v_370 
	* gender (including non-binary)
	label define gender 1 "male" 2 "female" 3 "non-binary" 
	label values gender gender	

	* gender = non-binary --> .
	mvdecode v_370, mv(3)
* male
	tab v_370, gen(n)
	rename n1 male
	label define male 0 "female" 1 "male"
	label value male male

	
	
gen age = v_125	

* agegroup
gen agegroup = .
replace agegroup = 6 if v_125 > 64 
replace agegroup = 5 if v_125 > 54 & v_125 <= 64
replace agegroup = 4 if v_125 > 44 & v_125 <= 54
replace agegroup = 3 if v_125 > 34 & v_125 <= 44
replace agegroup = 2 if v_125 > 24 & v_125 <= 34 
replace agegroup = 1 if v_125 > 15 & v_125 <= 24

label define agegroup 6 ">64" 5 "55-64" 4 "45-54" 3 "35-44" 2 "25-34" 1 "<25"
label value agegroup agegroup

recode v_20 (1 2 9 =1) (3 5 = 2) (4 11 = 4) (10 12 = 3)(7 = 5), gen(education)
label define edu 1 "Schulabbruch & Hauptschulabschluss (ISCED 2)" 2 "Mittlere Reife (ISCED 2)" 3 "Fachhochschulreife (ISCED 3)" 4 "Abitur (ISCED 3)" 5 "Hochschulabschluss (ISCED 5a)"
label value education edu

* east_west_south
recode bundesland (1 2 = 3) (3 4 8 13 14 16 = 1) (5 6 7 9 10 11 12 15 = 2), gen(east_west_south)
label define east_west_south 1 "East" 2 "North/West" 3 "South"
label value east_west_south east_west_south

* east_west_south_b (berlin bei West)
recode bundesland (1 2 = 3) (4 8 13 14 16 = 1) (3 5 6 7 9 10 11 12 15 = 2), gen(east_west_south_b)
label define east_west_south_b 1 "East" 2 "North/West" 3 "South"
label value east_west_south_b east_west_south_b

* links-rechts 0-1
gen left_right = (v_773 -1)/10
label define left_right 0 "links" 1 "rechts"
label value left_right left_right	

gen migration = v_57
replace migration = 0 if v_57 == 2

recode v_1143 (1 7 = 1) (2 = 2) (5 = 3) (3 = 4) (4 = 5) (6 = 6) (9 18 = 7) (97 98 = 9) (99 = 10) (else = 8), gen(vote_int)
	label define vote_intent2 1 "CDU/CSU" 2 "SPD" 3 "Left Party" 4 "Greens" 5 "FDP" 6 "AfD" 7 "Protest party" 8 "Others" 9 "Würde nicht wählen" 10 "Nicht wahlberechtigt"
	label values vote_int vote_intent2	

gen vacc = v_1134
replace  vacc = 1 if v_1133 == 1
replace vacc = 1 if v_1133 == 2
replace vacc = 4 if v_1134 == 3
replace vacc = 5 if v_1134 == 4
	
*** bereits geimpft

* nach agegroup
tab agegroup v_1133, row

* nach Geschlecht
tab v_370 v_1133, row

* nach links-rechts 0-1
tab left_right v_1133, row

* nach Parteineigung
tab parteineigung v_1133, row

* nach Sonntagsfrage
tab v_1143 v_1133, row

* nach Migrationshintergrund
tab v_57 v_1133, row

* nach Bildungsabschluss
tab v_20 v_1133, row

* nach Haushaltseinkommen
tab v_1131 v_1133, row

* nach Bundesland
tab v_19 v_1133, row

*** Impfabsicht bei Ungeimpften

* nach agegroup
tab agegroup v_1134, row

* nach Geschlecht
tab v_370 v_1134, row

* nach links-rechts 0-1
tab left_right v_1134, row

* nach Parteineigung
tab parteineigung v_1134, row

* nach Sonntagsfrage
tab v_1143 v_1134, row

* nach Migrationshintergrund
tab v_57 v_1134, row

* nach Bildungsabschluss
tab v_20 v_1134, row

* nach Haushaltseinkommen
tab v_1131 v_1134, row

* nach Bundesland
tab v_19 v_1134, row

gen household_income = v_1131
label define household_income  5 "Cope only with extreme difficulties" 4 "Cope with some difficulties" 3 "Cope" 2 "Live comfortably" 1 "Live very comfortably" 7 "Does not apply - no own household income yet"
label value household_income household_income


	*** Regression
	
	* b10 = NRW als Referenz
	* Modell A: Alter linear
	reg vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_3a.ster", replace
	
	* Modell A0: wie Modell A ohne vote_int
	reg vacc left_right b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_3_base.ster", replace
	
	* Modell B: Alter in Altersgruppen	
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education 
	estimates save "dump\wave_3b.ster", replace	
	
	* Modell C: household_income
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education i.household_income
	estimates save "dump\wave_3c.ster", replace

	* Modell D: migration background
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\wave_3d.ster", replace	
	
	* Modell E: own behavior
	* --> fehlt in wave 3	
	
	* Modell F: health
	* --> fehlt in wave 3	
	
	* Modell G: age x sex Interaktion
	reg vacc c.left_right i.vote_int b10.bundesland i.gender##c.age i.education 
	estimates save "dump\wave_3g.ster", replace	
	
	* Modell h: age x left_right Interaktion
	reg vacc c.left_right##c.age i.vote_int b10.bundesland i.gender i.education 
	estimates save "dump\wave_3h.ster", replace	
	
	* Modell i: age x left_right Interaktion
	reg vacc i.agegroup##c.left_right i.vote_int b10.bundesland i.gender   i.education 
	estimates save "dump\wave_3i.ster", replace	
	quietly margins , dydx(left_right ) at(agegroup=(1(1)6))
	marginsplot, title("S3 (August 2021)") xtitle("") ytitle("")
	graph save "dump\age_x_leftright_w3.gph", replace
	
	* Modell j: vote x left_right
	reg vacc i.vote_int##c.left_right b10.bundesland i.gender  i.agegroup   i.education 
	quietly margins  ,  at(vote_int=(1(1)6) left_right=(0 0.5 1)) 
	marginsplot, recast(scatter) title("Wave 3")
	graph save "dump\vote_left_right_3.gph", replace
	
	* Modell k: agegroup x vote_int x gender
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender b10.bundesland      i.education 
	estimates save "dump\wave_3k.ster", replace	
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S3 (August 2021) - Male") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w3_male.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S3 (August 2021) - Female") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w3_female.gph", replace
	grc1leg "dump\age_x_vote_w3_male.gph" "dump\age_x_vote_w3_female.gph", ycommon
	graph save "dump\age_x_vote_w3.gph", replace

	* Modell k: agegroup x vote_int x gender NOCI
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender b10.bundesland      i.education 
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S3 (August 2021) - Male") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 	/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w3_male_noci.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S3 (August 2021) - Female") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w3_female_noci.gph", replace
	grc1leg "dump\age_x_vote_w3_male_noci.gph" "dump\age_x_vote_w3_female_noci.gph", ycommon
	graph save "dump\age_x_vote_w3_noci.gph", replace	
	
	* Modell l: east_west_south x vote_int
	reg vacc c.left_right i.east_west_south##i.vote_int i.gender  i.agegroup i.education  
	estimates save "dump\wave_3l.ster", replace	
	margins, at(east_west_south = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S3 (August 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_x_vote_w3.gph", replace	

	* Modell lb: east_west_south_b x vote_int
	reg vacc c.left_right i.east_west_south_b##i.vote_int i.gender  i.agegroup i.education 
	margins, at(east_west_south_b = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S3 (August 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_b_x_vote_w3.gph", replace		

	*** als Ologit
		* Modell A: Alter linear
	ologit vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\ol_wave_3a.ster", replace
	
	* Modell B: Alter in Altersgruppen
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  
	estimates save "dump\ol_wave_3b.ster", replace	
	
	* Modell C: household_income
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  i.household_income
	estimates save "dump\ol_wave_3c.ster", replace

	* Modell D: migration background
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\ol_wave_3d.ster", replace	

	* Modell E: own behavior
	* --> fehlt in wave 3		
	
	* Modell F: health
	* --> fehlt in wave 3		

	collapse (mean) vacc_mean = vacc, by(bundesland)
	save "dump\vacc_mean_w3.dta"	, replace



clear all	
* WAVE 4 - 28.09-01.10.21
use "data\W4_Oct21.dta"

gen gender =  v_370 
	* gender (including non-binary)
	label define gender 1 "male" 2 "female" 3 "non-binary" 
	label values gender gender	

	* gender = non-binary --> .
	mvdecode v_370, mv(3)
* male
	tab v_370, gen(n)
	rename n1 male
	label define male 0 "female" 1 "male"
	label value male male


gen age = v_125	

* agegroup
gen agegroup = .
replace agegroup = 6 if v_125 > 64 
replace agegroup = 5 if v_125 > 54 & v_125 <= 64
replace agegroup = 4 if v_125 > 44 & v_125 <= 54
replace agegroup = 3 if v_125 > 34 & v_125 <= 44
replace agegroup = 2 if v_125 > 24 & v_125 <= 34 
replace agegroup = 1 if v_125 > 15 & v_125 <= 24

label define agegroup 6 ">64" 5 "55-64" 4 "45-54" 3 "35-44" 2 "25-34" 1 "<25"
label value agegroup agegroup

* east_west_south
recode bundesland (1 2 = 3) (3 4 8 13 14 16 = 1) (5 6 7 9 10 11 12 15 = 2), gen(east_west_south)
label define east_west_south 1 "east" 2 "west" 3 "south"
label value east_west_south east_west_south

* east_west_south_b (berlin bei West)
recode bundesland (1 2 = 3) (4 8 13 14 16 = 1) (3 5 6 7 9 10 11 12 15 = 2), gen(east_west_south_b)
label define east_west_south_b 1 "east" 2 "west" 3 "south"
label value east_west_south_b east_west_south_b

* links-rechts 0-1
gen left_right = (v_773 -1)/10
label define left_right 0 "links" 1 "rechts"
label value left_right left_right	

recode v_20 (1 2 9 =1) (3 5 = 2) (4 11 = 4) (10 12 = 3)(7 = 5), gen(education)
label define edu 1 "Schulabbruch & Hauptschulabschluss (ISCED 2)" 2 "Mittlere Reife (ISCED 2)" 3 "Fachhochschulreife (ISCED 3)" 4 "Abitur (ISCED 3)" 5 "Hochschulabschluss (ISCED 5a)"
label value education edu

gen migration = v_57
replace migration = 0 if v_57 == 2

recode v_1150 (2 8 = 1) (3 = 2) (6 = 3) (4 = 4) (5 = 5) (7 = 6) (13 = 7) (99 = 9) (98 = 10) (else = 8), gen(vote_int)
	label define vote_intent2 1 "CDU/CSU" 2 "SPD" 3 "Left Party" 4 "Greens" 5 "FDP" 6 "AfD" 7 "Protest party" 8 "Others" 9 "Würde nicht wählen" 10 "Nicht wahlberechtigt"
	label values vote_int vote_intent2	

gen vacc = v_1134
replace  vacc = 1 if v_1133 == 1
replace vacc = 1 if v_1133 == 2
replace vacc = 4 if v_1134 == 3
replace vacc = 5 if v_1134 == 4	

label define bundesland 1 "Baden-Wuerttemberg" 2 "Bavaria" 3 "Berlin" 4 "Brandenburg" 5 "Bremen" 6 "Hamburg" 7 "Hesse" 8 "Mecklenburg-Vorpommern" 9 "Lower Saxony" 10 "North Rhine-Westphalia" 11 "Rhineland Palatinate" 12 "Saarland" 13 "Saxony" 14 "Saxony-Anhalt"  15 "Schleswig Holstein" 16 "Thuringia"
label values bundesland bundesland
	
*** bereits geimpft

* nach agegroup
tab agegroup v_1133, row

* nach Geschlecht
tab v_370 v_1133, row

* nach links-rechts 0-1
tab left_right v_1133, row

* nach Parteineigung
tab parteineigung v_1133, row

* nach wen gewählt
tab v_1150 v_1133, row

* nach Migrationshintergrund
tab v_57 v_1133, row

* nach Bildungsabschluss
tab v_20 v_1133, row

* nach Haushaltseinkommen
tab v_1131 v_1133, row

* nach Bundesland
tab bundesland v_1133, row

*** Impfabsicht bei Ungeimpften

* nach agegroup
tab agegroup v_1134, row

* nach Geschlecht
tab v_370 v_1134, row

* nach links-rechts 0-1
tab left_right v_1134, row

* nach Parteineigung
tab parteineigung v_1134, row

* nach wen gewählt
tab v_1150 v_1134, row

* nach Migrationshintergrund
tab v_57 v_1134, row

* nach Bildungsabschluss
tab v_20 v_1134, row

* nach Haushaltseinkommen
tab v_1131 v_1134, row

* nach Bundesland
tab bundesland v_1134, row

gen household_income = v_1131
label define household_income  5 "Cope only with extreme difficulties" 4 "Cope with some difficulties" 3 "Cope" 2 "Live comfortably" 1 "Live very comfortably" 7 "Does not apply - no own household income yet"
label value household_income household_income

		*** Regression
	
	* b10 = NRW als Referenz
	* Modell A: Alter linear
	reg vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_4a.ster", replace
	
	* Modell A0: wie Modell A ohne vote_int
	reg vacc left_right b10.bundesland i.gender  age i.education 
	estimates save "dump\wave_4_base.ster", replace

	* Modell B: Alter in Altersgruppen
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education 
	estimates save "dump\wave_4b.ster", replace	
	
	* Modell C: household_income
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  i.household_income
	estimates save "dump\wave_4c.ster", replace

	* Modell D: migration background
	reg vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\wave_4d.ster", replace	
	
	* Modell E: own behavior
	* --> fehlt in wave 3	
	
	* Modell F: health
	* --> fehlt in wave 3	
	
	* Modell G: age x sex Interaktion
	reg vacc c.left_right i.vote_int b10.bundesland i.gender##c.age i.education 
	estimates save "dump\wave_4g.ster", replace	
	
	* Modell h: age x left_right Interaktion
	reg vacc c.left_right##c.age i.vote_int b10.bundesland i.gender i.education 
	estimates save "dump\wave_4h.ster", replace	
	
	* Modell i: age x left_right Interaktion
	reg vacc i.agegroup##c.left_right i.vote_int b10.bundesland i.gender   i.education 
	estimates save "dump\wave_4i.ster", replace	
	quietly margins, dydx(left_right ) at(agegroup=(1(1)6))
	marginsplot, title("S4 (October 2021)") xtitle("") ytitle("")
	graph save "dump\age_x_leftright_w4.gph", replace
	
	reg vacc i.vote_int##c.left_right b10.bundesland i.gender  i.agegroup  i.education 
	quietly margins  ,  at(vote_int=(1(1)6) left_right=(0 0.5 1)) 
	marginsplot, recast(scatter) title("Wave 4")
	graph save "dump\vote_left_right_4.gph", replace
	
	* Modell k: agegroup x vote_int x gender
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender b10.bundesland      i.education 
	estimates save "dump\wave_4k.ster", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S4 (October 2021) - Male") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w4_male.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S4 (October 2021) - Female") legend(row(3)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(dash))  		/// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(dash))				/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(dash))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(dash))			/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(dash))				/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(dash))	/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(dash))		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w4_female.gph", replace
	grc1leg "dump\age_x_vote_w4_male.gph" "dump\age_x_vote_w4_female.gph", ycommon
	graph save "dump\age_x_vote_w4.gph", replace

	* Modell k: agegroup x vote_int x gender NOCI
	reg vacc c.left_right i.agegroup##i.vote_int##i.gender  b10.bundesland     i.education 
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(1) ) 
	#delim ;
	marginsplot, title ("S4 (October 2021) - Male") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 	/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w4_male_noci.gph", replace
	quietly margins  ,  at( agegroup=(1(1)6) vote_int=(1(1)7) gender=(2) ) 
		#delim ;
	marginsplot, title ("S4 (October 2021) - Female") legend(row(2)) noci
				plot1opts(mcolor(black) lcolor(black) lpattern(solid))   		/// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) 				/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) 		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) 			/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) 				/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) 	/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) 		/// Protest
				recastci(rline) xtitle("") ytitle ("") yscale(range(0 6));
	#delimit cr
	graph save "dump\age_x_vote_w4_female_noci.gph", replace
	grc1leg "dump\age_x_vote_w4_male_noci.gph" "dump\age_x_vote_w4_female_noci.gph", ycommon
	graph save "dump\age_x_vote_w4_noci.gph", replace	
	
	* Modell l: east_west_south x vote_int
	reg vacc c.left_right i.east_west_south##i.vote_int i.gender  i.agegroup i.education 
	estimates save "dump\wave_4l.ster", replace
	margins, at(east_west_south = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S4 (October 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_x_vote_w4.gph", replace	

	* Modell lb: east_west_south_b x vote_int
	reg vacc c.left_right i.east_west_south_b##i.vote_int i.gender  i.agegroup i.education  
	margins, at(east_west_south_b = (1(1)3) vote_int = (1(1)7))
	set scheme plottigblind
		#delim ;
	mplotoffset,  offset(0.05)  xtitle("") ytitle ("") yscale(range(0 6))
	title ("S4 (October 2021)") legend(row(2)) 
				plot1opts(mcolor(black) lcolor(black) lpattern(solid)) ci1opt(color(black) lpattern(solid))  /// CDU
				plot2opts(mcolor (red)lcolor(red) lpattern(solid)) ci2opt(color(red) lpattern(solid))		/// SPD
				plot3opts(mcolor (purple)lcolor(purple) lpattern(solid)) ci3opt(color(purple) lpattern(solid))		/// Linke
				plot4opts(mcolor (green)lcolor(green) lpattern(solid)) ci4opt(color(green) lpattern(solid))		/// Grüne
				plot5opts(mcolor (gold)lcolor(gold) lpattern(solid)) ci5opt(color(gold) lpattern(solid))		/// FDP
				plot6opts(mcolor(eltblue) lcolor(eltblue) lpattern(solid)) ci6opt(color(eltblue) lpattern(solid))		/// AfD
				plot7opts(mcolor(sienna) lcolor(sienna) lpattern(solid)) ci7opt(color(sienna) lpattern(solid));		/// Protest
		#delimit cr
	graph save "dump\east_west_south_b_x_vote_w4.gph", replace	
	
	
	
	*** als Ologit
		* Modell A: Alter linear
	ologit vacc left_right i.vote_int b10.bundesland i.gender  age i.education 
	estimates save "dump\ol_wave_4a.ster", replace
	
	* Modell B: Alter in Altersgruppen
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  
	estimates save "dump\ol_wave_4b.ster", replace	
	
	* Modell C: household_income
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  i.household_income
	estimates save "dump\ol_wave_4c.ster", replace

	* Modell D: migration background
	ologit vacc left_right i.vote_int b10.bundesland i.gender  i.agegroup i.education  migration
	estimates save "dump\ol_wave_4d.ster", replace	

	* Modell E: own behavior
	* --> fehlt in wave 3		
	
	* Modell F: health
	* --> fehlt in wave 3	

	collapse (mean) vacc_mean = vacc, by(bundesland)
	save "dump\vacc_mean_w4.dta", replace	
	
	
	
* Table 1: Main Model
use "dump\forlabels.dta"
	qui reg vacc b10.bundesland i.gender  age i.education left_right i.vote_int
	estimates use "dump\wave_1a.ster" 
	eststo wave_1a
	
	estimates use "dump\wave_2a.ster" 
	eststo wave_2a 
	
	estimates use "dump\wave_3a.ster" 
	eststo wave_3a
	
	estimates use "dump\wave_4a.ster"
	eststo wave_4a
	
	esttab wave_1a wave_2a wave_3a wave_4a using "tables\table_1.rtf", label replace
	
* Table O1: Main Model without Vote_int
	estimates use "dump\wave_1_base.ster" 
	eststo wave_1base
	
	estimates use "dump\wave_2_base.ster" 
	eststo wave_2base
	
	estimates use "dump\wave_3_base.ster" 
	eststo wave_3base
	
	estimates use "dump\wave_4_base.ster"
	eststo wave_4base
	
	esttab wave_1base wave_2base wave_3base wave_4base using "tables\table_O1.rtf", label replace
	
* Table O2: Main Models with Age in Categories	
	estimates use "dump\wave_1b.ster" 
	eststo wave_1b
	
	estimates use "dump\wave_2b.ster" 
	eststo wave_2b
	
	estimates use "dump\wave_3b.ster"
	eststo wave_3b
	
	estimates use "dump\wave_4b.ster"
	eststo wave_4b
	
	esttab wave_1b wave_2b wave_3b wave_4b using "tables\table_O2.rtf", label replace
	
* Table O3: Main Models + Household Income
	estimates use "dump\wave_1c.ster"
	eststo wave_1c
	
	estimates use "dump\wave_3c.ster"
	eststo wave_3c
	
	estimates use "dump\wave_4c.ster"
	eststo wave_4c
	
	esttab wave_1c  wave_3c wave_4c using "tables\table_O3.rtf", label replace
	
* Table O4: Main Models + Migration Background
	estimates use "dump\wave_2d.ster"
	eststo wave_2d
	
	estimates use "dump\wave_3d.ster"
	eststo wave_3d
	
	estimates use "dump\wave_4d.ster"
	eststo wave_4d
	
	esttab wave_2d  wave_3d wave_4d using "tables\table_O4.rtf", label replace
	
* Table O5: Main Models + Health State
	estimates use "dump\wave_1f.ster"
	eststo wave_1f
	
	esttab wave_1f   using "tables\table_O5.rtf", label replace
	
* Table O6: Main Models + Own Behavior Regarding Covid-19 Recommendations
	estimates use "dump\wave_1e.ster" 
	eststo wave_1e
	
	estimates use "dump\wave_2e.ster" 
	eststo wave_2e
	
	esttab wave_1e wave_2e using "tables\table_O6.rtf", label replace
	
* Interaction model agegroup*left_right 
	estimates use "dump\wave_1i.ster" 
	eststo wave_1i
	
	estimates use "dump\wave_2i.ster" 
	eststo wave_2i 
	
	estimates use "dump\wave_3i.ster" 
	eststo wave_3i
	
	estimates use "dump\wave_4i.ster"
	eststo wave_4i
	
	esttab wave_1i wave_2i wave_3i wave_4i using "tables\table_O7.rtf", label replace
	
* Interaction model party_affiliation*agegroup*gender
	estimates use "dump\wave_1k.ster" 
	eststo wave_1k
	
	estimates use "dump\wave_2k.ster" 
	eststo wave_2k
	
	estimates use "dump\wave_3k.ster"
	eststo wave_3k
	
	estimates use "dump\wave_4k.ster"
	eststo wave_4k
	
	esttab wave_1k wave_2k wave_3k wave_4k using "tables\table_O8.rtf", label replace

* Interaction model party_affiliation*region
	estimates use "dump\wave_1l.ster" 
	eststo wave_1l
	
	estimates use "dump\wave_2l.ster"
	eststo wave_2l
	
	estimates use "dump\wave_3l.ster"
	eststo wave_3l
	
	estimates use "dump\wave_4l.ster"
	eststo wave_4l
	
	esttab wave_1l wave_2l wave_3l wave_4l using "tables\table_O9.rtf", label replace
	
	
	
	*** ORDINAL LOGIT as crosscheck not presented in the paper
	* main model age linear
	estimates use "dump\ol_wave_1a.ster" 
	eststo ol_wave_1a
	
	estimates use "dump\ol_wave_2a.ster"
	eststo ol_wave_2a 
	
	estimates use "dump\ol_wave_3a.ster"
	eststo ol_wave_3a
	
	estimates use "dump\ol_wave_4a.ster"
	eststo ol_wave_4a
	
	esttab ol_wave_1a ol_wave_2a ol_wave_3a ol_wave_4a using "dump\ol_models_1-4a.rtf", label replace eform
	
	* main model age groups
	estimates use "dump\ol_wave_1b.ster"
	eststo ol_wave_1b
	
	estimates use "dump\ol_wave_2b.ster"
	eststo ol_wave_2b
	
	estimates use "dump\ol_wave_3b.ster"
	eststo ol_wave_3b
	
	estimates use "dump\ol_wave_4b.ster"
	eststo ol_wave_4b
	
	esttab ol_wave_1b ol_wave_2b ol_wave_3b ol_wave_4b using "dump\ol_models_1-4.rtf", label replace eform
	
	* Income
	estimates use "dump\ol_wave_1c.ster"
	eststo ol_wave_1c
	
	estimates use "dump\ol_wave_3c.ster"
	eststo ol_wave_3c
	
	estimates use "dump\ol_wave_4c.ster"
	eststo ol_wave_4c
	
	esttab ol_wave_1c  ol_wave_3c ol_wave_4c using "dump\ol_models_1-4c.rtf", label replace eform
	
	* Migration Background
	estimates use "dump\ol_wave_2d.ster"
	eststo ol_wave_2d
	
	estimates use "dump\ol_wave_3d.ster"
	eststo ol_wave_3d
	
	estimates use "dump\ol_wave_4d.ster"
	eststo ol_wave_4d
	
	esttab ol_wave_2d  ol_wave_3d ol_wave_4d using "dump\ol_models_2-4d.rtf", label replace eform
	
	* health 
	estimates use "dump\ol_wave_1f.ster"
	eststo ol_wave_1f
	
	esttab ol_wave_1f   using "dump\ol_models_1f.rtf", label replace eform
	
	* own behavior
	estimates use "dump\ol_wave_1e.ster"
	eststo ol_wave_1e
	
	estimates use "dump\ol_wave_2e.ster" 
	eststo ol_wave_2e
	
	esttab ol_wave_1e ol_wave_2e using "dump\ol_models_1-2e.rtf", label replace eform
	
	
** Predictions Marginal Effects: vote_int x left_right
	grc1leg "dump\vote_left_right_1.gph" "dump\vote_left_right_2.gph" "dump\vote_left_right_3.gph" "dump\vote_left_right_4.gph" 
	graph export "dump\vote_left_right.pdf", replace

** Prediction age_x_gender_x_party	NOCI
	grc1leg "dump\age_x_vote_w1_male_noci.gph" "dump\age_x_vote_w1_female_noci.gph" "dump\age_x_vote_w2_male_noci.gph" "dump\age_x_vote_w2_female_noci.gph" "dump\age_x_vote_w3_male_noci.gph" "dump\age_x_vote_w3_female_noci.gph" "dump\age_x_vote_w4_male_noci.gph" "dump\age_x_vote_w4_female_noci.gph", ycommon col(2) imargins(0 0 0 0) name(grc1leg,replace) 
	gr draw grc1leg,  ysize(6) xsize(4)
	gr_edit .plotregion1.graph1.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph2.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph3.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph4.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph5.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph6.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph7.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph8.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	graph export "fig\Fig_7.pdf", replace
	graph export "fig\Fig_7.emf", replace	
	
	
** Prediction age_x_gender_x_party	CI
	grc1leg "dump\age_x_vote_w1_male.gph" "dump\age_x_vote_w1_female.gph" "dump\age_x_vote_w2_male.gph" "dump\age_x_vote_w2_female.gph" "dump\age_x_vote_w3_male.gph" "dump\age_x_vote_w3_female.gph" "dump\age_x_vote_w4_male.gph" "dump\age_x_vote_w4_female.gph", ycommon col(2) imargins(0 0 0 0) name(grc1leg,replace) 
	gr draw grc1leg,  ysize(6) xsize(4)
	gr_edit .plotregion1.graph1.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph2.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph3.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph4.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph5.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph6.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph7.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph8.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	graph export "dump\Fig_7_CI.pdf", replace
	graph export "dump\Fig_7_CI.emf", replace
	
** Prediction age x left_right
graph combine "dump\age_x_leftright_w1.gph" "dump\age_x_leftright_w2.gph" "dump\age_x_leftright_w3.gph" "dump\age_x_leftright_w4.gph", ycommon col(4) imargins(0 0 0 0) ysize(4) xsize(10)
gr_edit .AddTextBox added_text editor 2.895108695652174 -2.030163043478261
gr_edit .added_text_new = 1
gr_edit .added_text_rec = 1
gr_edit .added_text[1].style.editstyle  angle(default) size(medsmall) color(black) horizontal(left) vertical(middle) margin(zero) linegap(zero) drawbox(no) boxmargin(zero) fillcolor(black) linestyle( width(thin) color(black) pattern(solid) align(inside)) box_alignment(east) editcopy
gr_edit .added_text[1].style.editstyle size(vsmall) editcopy
gr_edit .added_text[1].text = {}
gr_edit .added_text[1].text.Arrpush Age group
gr_edit .added_text[1].DragBy -1.188858695652174 .8491847826086961
graph export "fig\Fig_6.pdf", replace
graph export "fig\Fig_6.emf", replace

** Prediction east_west_south x party (Berlin = East)
	grc1leg "dump\east_west_south_x_vote_w1.gph" "dump\east_west_south_x_vote_w2.gph" "dump\east_west_south_x_vote_w3.gph" "dump\east_west_south_x_vote_w4.gph", ycommon col(4) imargins(0 0 0 0) name(grc1leg,replace) ysize(6) xsize(6) 
	gr_edit .plotregion1.graph1.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph2.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph3.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph4.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	graph export "fig\Fig_5.emf", replace
	graph export "fig\Fig_5.pdf", replace
	
** Prediction east_west_south_b x party (Berlin = West)
	grc1leg "dump\east_west_south_b_x_vote_w1.gph" "dump\east_west_south_b_x_vote_w2.gph" "dump\east_west_south_b_x_vote_w3.gph" "dump\east_west_south_b_x_vote_w4.gph", ycommon col(4) imargins(0 0 0 0) name(grc1leg,replace) ysize(6) xsize(6)
	gr_edit .plotregion1.graph1.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph2.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph3.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	gr_edit .plotregion1.graph4.yaxis1.reset_rule 1 5 1 , tickset(major) ruletype(range)
	graph export "dump\Fig_5b.emf", replace
	graph export "dump\Fig_5b.pdf", replace
	
	
*** Comparison vaccine hesitancy - real vaccination rate	
clear all
	import excel "data\vacc_rate_bundeslaender.xlsx", sheet("vacc_rate") firstrow clear
	merge 1:1 bundesland using "dump\vacc_mean_w1.dta"
	rename vacc_mean vacc_mean_w1
	drop _merge
	merge 1:1 bundesland using "dump\vacc_mean_w2.dta"
	rename vacc_mean vacc_mean_w2
		drop _merge
	merge 1:1 bundesland using "dump\vacc_mean_w3.dta"
	rename vacc_mean vacc_mean_w3
		drop _merge
	merge 1:1 bundesland using "dump\vacc_mean_w4.dta"
	rename vacc_mean vacc_mean_w4
	drop if BL == ""
		
		drop _merge
	save "dump\comparison_BL_data.dta", replace
	
clear all
	import excel "data\hesitancy_BL.xlsx", sheet("hesitancy_BL_stata") firstrow clear	
	merge 1:1 bundesland using "dump\comparison_BL_data.dta"
	label define bundesland 1 "Baden-Wuerttemberg" 2 "Bavaria" 3 "Berlin" 4 "Brandenburg" 5 "Bremen" 6 "Hamburg" 7 "Hesse" 8 "Mecklenburg-Vorpommern" 9 "Lower Saxony" 10 "North Rhine-Westphalia" 11 "Rhineland Palatinate" 12 "Saarland" 13 "Saxony" 14 "Saxony-Anhalt"  15 "Schleswig Holstein" 16 "Thuringia"
	label values bundesland bundesland
	
	* vaccine hesitancy score October 21 vs vaccination rate 31.12.2021
	gen pos = 3
	replace pos = 6 if BL == "BW"
	replace pos = 9 if BL == "RP"
	replace pos = 6 if BL == "BR"	
	twoway (scatter vacc_rate_10_21 vacc_mean_w4, mlabel(bundesland) scale(0.7) legend(off) mlabpos(3) mlabv(pos) mlabgap(*.5) xtitle("Mean vaccination hesitancy October 2021") ytitle("Percent with basic immunization on 31 October 2021")) (lfit vacc_rate_10_21 vacc_mean_w4, range(1 1.8))
	graph export "dump\Fig_4a.emf", replace
	graph export "dump\Fig_4a.pdf", replace
	
	
	* vaccine hesitancy score February 21 vs vaccination rate 31.12.2021
	replace pos = 6 if BL == "MV"
	replace pos = 9 if BL == "BW"
	twoway 	(scatter vacc_rate_12_21 vacc_mean_w1, mlabel(bundesland) scale(0.7) legend(off) mlabpos(3) mlabv(pos) mlabgap(*.5) xtitle("Mean vaccination hesitancy February 2021") ytitle("Percent with basic immunization on 31 December 2021")) ///
			(lfit vacc_rate_12_21 vacc_mean_w1, range(1.5 3))
	graph export "dump\Fig_4b.emf", replace
	graph export "dump\Fig_4b.pdf", replace

	
	gen no_vacc_rate_12_21 = 100-vacc_rate_12_21
	
	* % vaccine hesitant February 21 vs percentage not vaccinated 31.12.2021
	replace pos = 3 if BL == "MV"
	replace pos = 9 if BL == "BW"
	replace pos = 9 if BL == "ST"
	twoway 	(scatter no_vacc_rate_12_21 hesitant_w1, mlabel(bundesland) scale(0.7) legend(off) mlabpos(3) mlabv(pos) mlabgap(*.5) xtitle("Percent (clearly + rather) vaccine hesitant in February 2021") ytitle("Percent without basic immunization on 31 December 2021")) ///
			(lfit no_vacc_rate_12_21 hesitant_w1, )
	graph export "fig\Fig_4.emf", replace
	graph export "fig\Fig_4.pdf", replace
	
	* % vaccine hesitant October 21 vs percentage not vaccinated 31.12.2021
	replace pos = 12 if BL == "MV"
	replace pos = 9 if BL == "BW"
	replace pos = 3 if BL == "BR"
	twoway 	(scatter no_vacc_rate_12_21 hesitant_w4, mlabel(bundesland) scale(0.7) legend(off) mlabpos(3) mlabv(pos) mlabgap(*.5) xtitle("Percent (clearly + rather) vaccine hesitant in October 2021") ytitle("Percent without basic immunization on 31 December 2021")) ///
			(lfit no_vacc_rate_12_21 hesitant_w4, range(0 20) )
	graph export "dump\Fig_4c.emf", replace
	graph export "dump\Fig_4c.pdf", replace
